package xj.graph2d.template.uml;

import xj.graph2d.AbstractModelListener;
import xj.graph2d.DrawShape;
import xj.graph2d.GraphNodeBase;
import xj.model.uml.UMLSystem;

public class UMLSystemModelListener extends AbstractModelListener {

  public UMLSystemModelListener() {
  }

  public UMLSystemModelListener(Object model, DrawShape shape) {
    super(model, shape);
  }

  @Override
  public void updateModel() {
    if (shape instanceof GraphNodeBase && model instanceof UMLSystem) {
      GraphNodeBase sysnode = (GraphNodeBase) shape;
      UMLSystem sysmodel = (UMLSystem) model;
      String name = sysnode.getLabel();
      if (name != null) {
	sysmodel.setName(name);
      }
    }
  }

  @Override
  public void updateShape() {
    if (shape instanceof GraphNodeBase && model instanceof UMLSystem) {
      GraphNodeBase sysnode = (GraphNodeBase) shape;
      UMLSystem sysmodel = (UMLSystem) model;
      String name = sysmodel.getName();
      if (name != null) {
	sysnode.setLabel(name);
      }
    }
  }

}
